package com.neusoft.ysu.populationmanagement.controller;


import com.neusoft.ysu.populationmanagement.entity.CommonResult;

import com.neusoft.ysu.populationmanagement.entity.IdCard;
import com.neusoft.ysu.populationmanagement.service.IIdCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2024-06-24
 */
@RestController
@RequestMapping("/id-card")
@CrossOrigin
public class IdCardController {
    @Autowired
    IIdCardService idCardService;

    @RequestMapping("/apllyIdCard")
    public CommonResult apllyIdCard(String idnum, Long pid, Long operatorId) {
        return idCardService.apllyIdCard(idnum,pid,operatorId);
    }

    @RequestMapping("/buildIdCard")
    public CommonResult buildIdCard(String idnum,Long pid,Long operatorId) {
        return idCardService.buildIdCard(idnum,pid,operatorId);
    }

    @RequestMapping("/finishIdCard")
    public CommonResult finishIdCard(String idnum,Long pid,Long operatorId) {
        return idCardService.finishIdCard(idnum,pid,operatorId);
    }

    @RequestMapping("/sendIdCard")
    public CommonResult sendIdCard(String idnum,Long pid,Long operatorId) {
        return idCardService.sendIdCard(idnum,pid,operatorId);
    }

    @RequestMapping("/lossIdCard")
    public CommonResult lossIdCard(String idnum,Long pid,Long operatorId) {
        return idCardService.lossIdCard(idnum,pid,operatorId);
    }

    @RequestMapping("/deleteIdCard")
    public CommonResult deleteIdCard(String idnum,Long pid,Long operatorId) {
        return idCardService.deleteIdCard(idnum,pid,operatorId);
    }

    @RequestMapping("/selectIdCardByIdnum")
    public CommonResult selectIdCardByIdnum(String idnum) {
        List<IdCard> list = idCardService.selectIdCardByIdnum(idnum);
        if (list.isEmpty()) {
            return new CommonResult<>(0, "未查到对应身份证", list);
        } else {
            return new CommonResult<>(1, "查询成功",list );
        }
    }
}
